﻿using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using WpfAnimationDemo.Controls.WaferRobot;

namespace WpfAnimationDemo.Views
{
    /// <summary>
    /// RobotView.xaml 的交互逻辑
    /// </summary>
    public partial class RobotView : UserControl
    {
        public RobotView()
        {
            //https://www.cnblogs.com/wwwen/p/17076289.html
            InitializeComponent();
        }

        private void ZCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotZAction = WaferRobotZAction.Z_CW;
        }

        private void ZCCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotZAction = WaferRobotZAction.Z_CCW;
        }

        private void XCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotXAction = WaferRobotXAction.X_CW;
        }

        private void XCCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotXAction = WaferRobotXAction.X_CCW;
        }

        private void TCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotTAction = WaferRobotTAction.T_CW;
        }

        private void TCCWButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotTAction = WaferRobotTAction.T_CCW;
        }

        private async void AutoButton_Click(object sender, RoutedEventArgs e)
        {
            robot.RobotTAction = WaferRobotTAction.T_CCW;
            await Task.Delay(1000);

            robot.RobotXAction = WaferRobotXAction.X_CW;
            await Task.Delay(2000);

            robot.Wafer = 1;
            await Task.Delay(200);

            robot.RobotXAction = WaferRobotXAction.X_CCW;
            await Task.Delay(2000);

            robot.RobotZAction = WaferRobotZAction.Z_CW;
            await Task.Delay(1000);

            robot.RobotTAction = WaferRobotTAction.T_CW;
            await Task.Delay(1000);

            robot.RobotXAction = WaferRobotXAction.X_CW;
            await Task.Delay(2000);

            robot.Wafer = 0;
            await Task.Delay(200);

            robot.RobotXAction = WaferRobotXAction.X_CCW;
            await Task.Delay(2000);

            robot.RobotTAction = WaferRobotTAction.T_Origin;
            await Task.Delay(1000);

            robot.RobotZAction = WaferRobotZAction.Z_CCW;
        }
    }
}
